/**
 * Author:  Sanket Hiremath
   ----------------------------------------------------------------------
   	Copyright (C) Sanket Hiremath, 2020

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

   ----------------------------------------------------------------------
 */
#include "math.h"
#include "sys.h"
#include "iic_soft.h"
#ifndef OPT3001_H_
#define OPT3001_H_



#define OPT3001_ADDR1 0x44        //GND (Default)
#define OPT3001_ADDR2	0x45        //VDD
#define OPT3001_ADDR3	0x46        //SDA
#define OPT3001_ADDR4	0x47		    //SCL

#define OPT3001_ResultReg	  0x00
#define OPT3001_ConfigReg	  0x01
#define OPT3001_SetLow	    0x02
#define OPT3001_SetHigh     0x03
#define OPT3001_ManuID      0x7E
#define OPT3001_DeviceID    0x7F



void opt3001_writedata(IIC_enum IIC_channel,u8 dev,u8 register_addr, u16 data); //This function is used to write data to different registers.

u16 opt3001_readdata(IIC_enum IIC_channel,u8 dev,u8 reg);         //This function is used to read raw data from different registers.

u8 opt3001_init(IIC_enum IIC_channel,u8 dev);              //Initialize the sensor

void calculate_lux(IIC_enum IIC_channel,u8 dev,float* light ,u16* rwa_hex);               //get the ambient light level value from the sensor(in Lux)

u16 read_devid(IIC_enum IIC_channel,u8 dev);              //Read the device id

u16 read_manufacturer_id(IIC_enum IIC_channel,u8 dev);    //Read the manufacturer id

u8 opt3001_get_lux(void);


#endif /* OPT3001_H_ */
